package com.hsq.reflection.Class_;

import com.hsq.reflection.Car;

import java.io.Serializable;

public class GetClass {
    public static void main(String[] args) throws ClassNotFoundException {
        String classAllPath = "com.hsq.reflection.Car";
        //第一种
        Class cls1 = Class.forName(classAllPath);
        //第二章
        Class cls2 = Car.class;
        //第三种
        Car car = new Car();
        Class cls3 = car.getClass();
        //第四，通过类加载器[4种]
//        (1) 先得到类加载器car
        ClassLoader classLoader = car.getClass().getClassLoader();
        //(2)在通过类加载器得到Class对象
        Class cls4 = classLoader.loadClass(classAllPath);
        System.out.println(cls1);
        System.out.println(cls2);
        System.out.println(cls3);
        System.out.println(cls4);
        System.out.println(cls1.hashCode());
        System.out.println(cls2.hashCode());
        System.out.println(cls3.hashCode());
        System.out.println(cls4.hashCode());
        System.out.println("==============");
        //基础类型
        Class<Integer> integerClass = int.class;
        Class<Character> characterClass = char.class;
        Class<Boolean> booleanClass = boolean.class;
        System.out.println(integerClass);//int
        //包装类
        Class<Integer> type = Integer.TYPE;
        Class<Character> type1 = Character.TYPE;
        System.out.println(type);

        System.out.println(integerClass.hashCode());
        System.out.println(type.hashCode());
        //还有哪些有Class对象
        Class<String> cls1_ = String.class;
        Class<Serializable> cls2_ = Serializable.class;
        Class<Integer[]> cls3_ = Integer[].class;
        Class<float[][]> cls4_ = float[][].class;
        Class<Deprecated> cls5 = Deprecated.class;
        Class<Thread.State> cls6 = Thread.State.class;
        Class<Long> cls7 = long.class;
        Class<Void> cls8 = void.class;
        Class<Class> cls9 = Class.class;
        System.out.println(cls1_);
        System.out.println(cls2_);
        System.out.println(cls3_);
        System.out.println(cls4_);
        System.out.println(cls5);
        System.out.println(cls6);
        System.out.println(cls7);
        System.out.println(cls8);
        System.out.println(cls9);

    }
}
